<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!--
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.10.0/jquery.js"></script>
    -->
    <script src="/jquery/jquery-3.6.0.min.js"></script>
    <script src="/jquery/jquery.cookie.js"></script>
    <script src="/bootstrap/js/bootstrap.min.js"></script>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <!--
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
    <script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    -->
    

    <!-- Bootstrap CSS -->
<!--    <link rel="stylesheet" href="/css/bootstrap.css">-->
    <!--
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css" rel="stylesheet">
    -->
    <link href="/bootstrap/css/bootstrap.css" rel="stylesheet">

    <style>
        .container .header {
            margin-top: 45px;
        }

        .container .row h1 {
            text-align: center;
            background-color: #f5f5f5;
        }
        .container .row .btn-group button {
            margin-top: 25px;
        }
        .container .row .btn-group button {
            margin-left: 50px;            
        }
        #submitBtn {
            width: 100px;
        }
    </style>

    <title>登录</title>

</head>
<body>
<div class="container">
    <div class="row header">
        <div class="col-xs-6 col-md-4"></div>
        <div class="col-xs-6 col-md-4"><h1>登录</h1></div>
        <div class="col-xs-6 col-md-4"></div>
    </div>

    <div class="row">
        <div class="col-xs-6 col-md-4"></div>
        <div class="col-xs-6 col-md-4">  
            <form>
                <div class="form-group">
                    <label for="reg-email">用户名</label>
                    <input type="email" class="form-control" id="reg-email" placeholder="请输入邮箱">

                </div>
                <div class="form-group">
                    <label for="reg-password">密码</label>
                    <input type="password" class="form-control" id="reg-password" placeholder="请输入密码">
                </div>
                <div class="btn-group">
                <button type="button" id="submitBtn" class="btn btn-primary">登录</button>
                <button type="button" id="registerBtn" class="btn btn-primary">&gt;&gt;注册</button>                
                </div>                
            </form>
        </div>
        <div class="col-xs-6 col-md-4"></div>
</div>

</body>

<script>
    $(function() {
        var domain = "http://localhost";
        //http://localhost:9003/api/user/login/jlchen2002xg@126.com/1233456/
        //http://localhost:9003/api/user/login/jlchen2002xg@126.com/1233456/
        //http://localhost/api/user/login/jlchen2002xg@126.com/1233456

        $.removeCookie('token', { path: '/' ,domain:".www.test.com"});
        $("#registerBtn").on("click",function () {
            location.href = "register.html";
        });
        // Handler for .ready() called.
        $("#submitBtn").on("click",function () {
            var email = $("#reg-email").val();
            var password = $("#reg-password").val();
            $.ajax({
                 //url: "http://localhost:9002/api/user/login/"+email+"/"+password,
                url: domain + "/api/user/login/"+email+"/"+password,
                type: "GET",
                success:function (data) {
                    if(data == "false"){
                        alert("登陆失败")
                    }else{
                        location.href = "welcome.html";
                    }
                }
                //dataType: "text"
            })
        })
    });
</script>

</html>